<template>
  <div class="divBox">

    <el-card class="box-card">

      <el-table v-loading="formLoading" :data="listData.data" style="width: 100%" size="small" highlight-current-row>
        <el-table-column prop="id" label="ID" min-width="80"/>
        <el-table-column prop="verificationCode" label="券码" min-width="100"/>
        <el-table-column prop="userVoucher" label="劵额" min-width="100"/>
        <el-table-column prop="voucher" label="兑换金额" min-width="60"/>
        <el-table-column prop="expirationTime" label="过期时间" min-width="100"/>
        <el-table-column prop="usageTime" label="兑换时间" min-width="120"/>
        <el-table-column prop="status" label="激活状态" min-width="80">
          <template slot-scope="scope">
            <span v-if="scope.row.status===1">待激活</span>
            <span v-if="scope.row.status===2">待分享</span>
            <span v-if="scope.row.status===3">待使用</span>
            <span v-if="scope.row.status===4">已核销</span>
            <span v-else-if="scope.row.status===5">已失效</span>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          :current-page="listPram.page"
          :page-sizes="[20,40,60,80,100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="listData.count"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </el-card>
  </div>
</template>
<script>
import {detail} from "@/api/consumption";

export default {
  components: {},
  props: {
    id: {
      default: null
    }
  },
  data() {
    return {
      type: 2,
      value1: '',
      recordName: 'couponObtain',
      formLoading: true,
      listData: {list: [], count: 0},
      listPram: {
        page: 1,
        limit: 20,
        orderId: '',
      },
    }
  },
  mounted() {
    if (this.id) {
      console.log(this.id)
      this.getDetail();
    }
  },
  methods: {
    onchangeTime(e) {
      this.timeVal = e;
      this.listPram.dateLimit = e ? this.timeVal.join(',') : '';
    },
    handleClick() {
      this.listPram.dateLimit = '';
      this.value1 = '';
      this.getDetail()
    },
    getDetail() {
      this.formLoading = true
      this.listPram.orderId = this.id

      detail(this.listPram).then(res => {
        this.listData.data = res
      }).finally(() => {
        this.formLoading = false;
      })
    },
    handlerSubmit() {
      if (this.saveLoading || this.formLoading) {
        return;
      }
    },
    close() {
      this.$emit('hideEditDialog')
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.getList()
    },
  }
}
</script>

<style scoped lang="scss">
::v-deep {
  .el-upload {
  }
}

.img {
  width: 80px;
  height: 80px;
  border-radius: 100px;
}
</style>
